package com.heima.admin.controller.v1;

import com.heima.admin.service.AdChannelService;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.admin.pojos.AdChannel;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author liuyaning
 * @version 1.0
 * @date 2021/7/29 14:55
 */
@Api(value = "频道管理", tags = "channel", description = "频道管理API")
@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelController {
    @Autowired
    private AdChannelService adChannelService;

    @ApiOperation("分页获取频道列表")
    @PostMapping("/list")
    public ResponseResult list(@RequestBody ChannelDto channelDto){
        return  adChannelService.list(channelDto);
    }
    @ApiOperation("新增频道")
    @PostMapping("/save")
    public ResponseResult add(@RequestBody AdChannel adChannel){
        return adChannelService.insert(adChannel);
    }
    @ApiOperation("更新频道")
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdChannel adChannel){
        return adChannelService.update(adChannel);
    }
    @ApiOperation("删除指定频道")
    @GetMapping("/del{id}")
    public ResponseResult del(@PathVariable("id") Integer id){
        return adChannelService.del(id);
    }
}
